package com.tianji.learning.controller;

import com.tianji.api.dto.leanring.LearningLessonDTO;
import com.tianji.learning.domain.dto.LearningRecordFormDTO;
import com.tianji.learning.service.ILearningRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 学习记录表 前端控制器
 * </p>
 *
 * @author hzy
 * @since 2023-09-07
 */
@RestController
@RequestMapping("/learning-records")
@RequiredArgsConstructor
@Slf4j
public class LearningRecordController {

    private final ILearningRecordService recordService;

    /**
     * 查询指定课程的学习记录
     *
     * @param courseId
     * @return
     */
    @ApiOperation("查询指定课程的学习记录")
    @GetMapping("/course/{courseId}")
    public LearningLessonDTO selectLessonRecord(@PathVariable("courseId") Long courseId) {
        return recordService.selectLessonRecord(courseId);
    }

    /**
     * 提交学习记录
     *
     * @param dto
     */
    @PostMapping
    @ApiOperation("提交学习记录")
    public void commitRecord(@RequestBody LearningRecordFormDTO dto) {
        recordService.commitRecord(dto);
    }


}
